#ifndef RICHERPLUGIN_H
#define RICHERPLUGIN_H

#include <QMap>
#include <QList>

#include "pluginbase.h"

class Good
{
public:
    int id;
    long long price;
    QList<long long> prices;
    QMap<long long, long long> counts;
    QString name;

    int category;
    double interst;
    QList<int> buyCount;

    inline int findNearestBuyCount(int count)
    {
        int ret = 0;
        QList<int>::Iterator it = buyCount.begin();
        while(it != buyCount.end())
        {
            int c = *it;
            if(c <= count && c > ret)
                ret = c;
            ++it;
        }
        return ret;
    }
};

class RicherPlugin;
class RicherConfig : public PluginConfigBase
{
public:
    bool doRicher;
    bool doBuy;
    bool doSell;
    bool doGather;

    int lastOp;
    int lastObj;

    long long money;
    long long store;

    int buyGood;
    int buyCount;

    QList<int> goodToBuy;
    QList<int> goodToSell;


    RicherConfig(RicherPlugin* plugin)
        : PluginConfigBase((PluginBase*)plugin), lastOp(0), lastObj(0)
    {
        money = 0;
    }
};

class RicherPlugin : public PluginBase
{
Q_OBJECT
public:
    public:
        QMap<int, Good*> goodMap;
        uint updateInterval;
        int uid;

        uint lastUpdated;

        explicit RicherPlugin(QObject *parent = 0);
        virtual void singleSave(QSettings* settings, Account* act);
        virtual void singleLoad(QSettings* settings, Account* act);
        virtual ConfigWidgetBase* createConfigWidget(Account* act);

        virtual int start(Account* act, int stage = -1);

    signals:

    public slots:
};

#endif // RICHERPLUGIN_H
